import os
from PyQt4.QtCore import *
import sys

def getName():
    if os.name == "nt":
        return "windows"
    if os.name == "posix":
        if sys.platform == "darwin":
            return "mac"
        import platform
        uname = platform.uname()
        if (uname[0] == "Linux") and (uname[1].find("Nokia") >= 0):
            return "maemo"
        import subprocess
        try:
            p = subprocess.Popen("xlsclients", stdout = subprocess.PIPE)
            for client in p.stdout.readlines():
                if client.find("gnome-session") >= 0:
                    return "gnome"
                elif client.find("ksmserver") >= 0:
                    return "kde"
            p.wait()
        except:
            pass
        return "x11"
    if os.name == "mac":
        return "mac"
    return "unknown"

name = getName()
QDir.addSearchPath("icon", ":/res/" + name)
QDir.addSearchPath("icon", ":/res/default")
